/************************************************************************
                        Interface.h.cpp - Copyright asaf
*/

#include "Interface.h"
#include "AuthenticationManager.h"
#include "UserInteractionUnit.h"
#include "InterfaceLogic.h"
#include "..\dc\DataContainer.h"
// ctor/dtor
Interface::Interface (DataContainer &t_dc):m_dc(t_dc){initAttributes();}//
Interface::~Interface ( ) {}
AuthenticationManager& Interface::getAm ( ) {return *m_am;}
DataVerificator& Interface::getDv ( ) {return *m_dv;}
UserInteractionUnit& Interface::getUiu ( ) {return *m_uiu;}
InterfaceLogic& Interface::getIfcl ( ) {return *m_ifcl;}
DataContainer& Interface::getDc ( ){return m_dc;}
int Interface::getUserPermissionLevel(){return m_loggedPerson.getPermission();}
void Interface::setUserPermissionLevel(int t_userPermissionLevel){m_loggedPerson.setPermission(t_userPermissionLevel);}
string Interface::getLoggedUserId(){return m_loggedPerson.getID();}
void Interface::setLoggedUserId(string userID){m_loggedPerson.setID(userID);}
int Interface::getUserSemester(){return m_loggedPerson.getSemester();}
void Interface::setUserSemester(int t_userSemester){m_loggedPerson.setSemester(t_userSemester);}
string Interface::getLoggedUserName(){
	return m_loggedPerson.getFirstName()+" "+m_loggedPerson.getLastName();
}

auto_ptr<Reply> Interface::userRequest (const Request &request) {return m_uiu->userRequest(request);}

void Interface::initAttributes ( ) {
		m_am =  auto_ptr<AuthenticationManager>(new AuthenticationManager(*this));
		m_dv =  auto_ptr<DataVerificator>(new DataVerificator());
		m_uiu = auto_ptr<UserInteractionUnit>(new UserInteractionUnit(*this));
		m_ifcl= auto_ptr<InterfaceLogic>(new InterfaceLogic (*this));
}
